package com.cy.db.common.pojo;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;
/**基于此对象封装分页信息*/
@Data
@NoArgsConstructor
public class PageObject<T> implements Serializable {
    private static final long serialVersionUID = -5715616403473721329L;
    /**总记录数*/
    private Long rowCount;
    /**当前页记录*/
    private List<T> records;
    /**总页数*/
    private Long pageCount;
    /**页面大小(每页最多显示多少条记录)*/
    private Integer pageSize;
    /**当前页码值*/
    private Long pageCurrent;

    public PageObject(Long rowCount, List<T> records, Long pageCount,
                      Integer pageSize, Long pageCurrent) {
        super();
        this.rowCount = rowCount;
        this.records = records;
        this.pageCount = pageCount;
        this.pageSize = pageSize;
        this.pageCurrent = pageCurrent;
    }

    public PageObject(Long rowCount, List<T> records, Integer pageSize, Long pageCurrent) {
        super();
        this.rowCount = rowCount;
        this.records = records;
        this.pageSize = pageSize;
        this.pageCurrent = pageCurrent;
        //计算pageCount的值
        this.pageCount = (this.rowCount-1)/pageSize+1;
    }
}
